<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<link rel="stylesheet" href="${initParam.root }/css/board/main_boardShowContent.css">
<script type="text/javascript">

$(document).ready(function(){
	
	$("#deleteContent").click(function(){
		var flag=confirm("삭제하시겠습니까?");
		if(flag)
			location.href="board.do?command=deleteContent&b_no="+'${requestScope.bvo.b_no}';
	})//click
	
	$("#updateContent").click(function(){
		if('${requestScope.bvo.m_id}'!='${sessionScope.loginMember.mvoLogin.m_id}'){
			alert("작성자만 수정할 수 있습니다.");
			return
		}else if(confirm("수정하시겠습니까?")){
			location.href="board.do?command=updateContentPage&b_title="+'${requestScope.bvo.b_title}'+"&b_content="+
					'${requestScope.bvo.b_content}'+"&bno="+
					'${requestScope.bvo.b_no}';
		}
	})//click
	$("#showQnaList").click(function(){
		var flag=confirm("목록으로 이동하시겠습니까?");
		if(flag)
			location.href="board.do?command=findAllQnaforPaging";
	});//click
	$("#writeReply").click(function(){
		var flag=confirm("답글을 작성하시겠습니까?");
		if(flag)
			location.href="board.do?command=QnaReplyView&bno=${requestScope.bvo.b_no}";
	});
	
	//댓글 등록 버튼
	$("#reply_writeBtn").click(function(){
		if(${sessionScope.loginMember==null}){
			alert("로그인하셔야 이용가능합니다.");
		}else if($("#board_content").val()==""||$("#board_content").val()=="로그인후 작성가능합니다."){
			alert("댓글을 입력하세요");
		}else{
			if(confirm("댓글을 등록하시겠습니까?")){
				if($(":hidden[name=page]").val()=="next"){
					$(":hidden[name=rpage]").val($(":hidden[name=page]").val());
				}else{
					$(":hidden[name=rpage]").val(($(":hidden[name=page]").val()-1));
				}
				$("#replyForm").submit();
			}
		}
	});
	// 리플삭제
	$(".deleteReplyBtn").click(function(){
		var board_no=$(this).find(":hidden[name=board_no]").val();
		if('${sessionScope.loginMember.mvoLogin.m_id }'!='${requestScope.bvo.m_id}'){
			alert("삭제권한이 없습니다");
			return;
		}else if(confirm("해당게시글을 삭제하시겠습니까?")){
			location.href="board.do?command=delReply&board_no="+board_no+"&b_no="+${requestScope.bvo.b_no};
		}
	});
});//ready
</script>
<div id="전체틀">
	<div id="컨텐츠">
		<table  id="content">
			<tr class="tr_title">
				<td width="10%">no ${requestScope.bvo.b_no}</td><td width="72%" class="td_title"><b>${requestScope.bvo.b_title}</b></td>
				<td width="18%" class="td_date">${requestScope.bvo.b_date}</td>
			</tr>
			<tr class="tr_title2">
				<td colspan="3">${requestScope.bvo.b_writer} count ${requestScope.bvo.b_cnt}</td>
			</tr>
			<c:if test="${requestScope.bvo.orgfilename!=null }">
				<tr>
					<td colspan="3" align="right">
						<font size="2">
							파일 다운로드 : <a href="${initParam.root}/board.do?command=fileDownload&newfilename=${requestScope.bvo.newfilename }
						&orgfilename=${requestScope.bvo.orgfilename }">${requestScope.bvo.orgfilename }</a>
						</font>
					</td>
				</tr>
			</c:if>
			<tr>
				<td colspan="3" class="td_content">
					<pre>${requestScope.bvo.b_content}</pre>
				</td>
			</tr>
		</table><!-- content -->
	</div><!-- 컨텐츠 -->
	<div id="btn">
		<ul>
			<li><img src="${initParam.root }/img/paging/answer_btn.jpg" alt="답글" id="writeReply"></li>
			<c:if test="${sessionScope.loginMember.mvoLogin.m_id ==requestScope.bvo.m_id }">
			<li><img src="${initParam.root }/img/paging/modify_btn.jpg" alt="수정" id="updateContent"></li>
			<li><img src="${initParam.root }/img/paging/delete_btn.jpg" alt="삭제" id="deleteContent"></li>
			</c:if>
			<li><img src="${initParam.root }/img/paging/list_btn.jpg" alt="목록" id="showQnaList"></li>
		</ul>
	</div><!-- btn --><br><br><br>
<div class="replyTableBack" style="width: 800px;height: 130px;background-color: #f7f7f7;"><br>
 		<!-- 댓글 등록 테이블 -->
 		<table class="replyTable">
 			<tr align="left" height="30">
 				<td colspan="2"><img src="${initParam.root }/img/foot/reply/footer-reply-title.gif"></td>
 			</tr>
 			<tr>
 				<td>
 					<form id="replyForm" method="post" action="board.do" name="replyForm"> 
 					<input type="hidden" name="command" value="BoardReply">
 					<input type="hidden" name="b_no" value="${requestScope.bvo.b_no}">
					<textarea cols="75" rows="4"  id="board_content" name="board_content"></textarea>
 					</form>
 				</td>
 				<td><input type="button" id="reply_writeBtn" value="등록"class="button_img" style="width:70px; height:70px; background-color:#c1c1c1;"></td>
 			</tr>
 		</table></div><br><br><br><br>
 		
<div class="replyCenter">
			<!-- 댓글 리스트 테이블 -->
		 <table class="replyListTable">
		 	  <colgroup>
                   <col width="100px"/>
                   <col width="180px"/>
                   <col />
             </colgroup>
            <c:forEach var="reply" items="${requestScope.list }">
			 	<c:choose>
			 		<c:when test="${reply.m_type=='a' }">
			 			<tr class="replyListTable_tr_admin">
			 		</c:when>
			 		<c:otherwise>
			 			<tr class="replyListTable_tr">
			 		</c:otherwise>
			 	</c:choose>
		 			<td align="center" ><b>${reply.m_name }</b></td>
		 			<td align="center" >${reply.m_id}<br><span style="color: #999999">${rrvo.board_date }</span><br>
		 				<c:choose>
			 				<c:when test="${reply.m_id==sessionScope.loginMember.mvoLogin.m_id}">
			 						<span class="deleteReplyBtn">
 									<input type="hidden" name="rep_no" value="${reply.board_no }">
 									<input type="hidden" name="m_id" value="${reply.m_id }">
			 						<input type="button" id="delReplyBtn" value="삭제" class="button_img" style="background-color:#c1c1c1; width: 45px;">
			 						</span>
			 				</c:when>
			 				<c:when test="${sessionScope.loginMember.mvoLogin.m_type=='a' }">
 									<span  class="deleteReplyBtn">
 									<input type="hidden" name="rep_no" value="${reply.board_no }">
 									<input type="hidden" name="m_id" value="${reply.m_id }">
									<input type="button" id="delReplyBtn" value="삭제" class="button_img" style="background-color:#c1c1c1; width: 45px;">
									</span>
			 				</c:when>
			 			</c:choose>
		 			</td>
		 			<td>
		 				<table width="100%">
		 					<tr><td style="text-align: left; word-break:break-all;">${reply.board_content }</td></tr>
		 				</table><br>

		 			</td>
		 		</tr>
		 	</c:forEach>
		 </table>
</div><!-- 전체틀 -->

<br><br><hr width="1024px"><br>
<div><img src="${initParam.root }/img/foot/foot-01-img.gif" class="copyright"></div>
		<br><br>
	
	</div>
</div><!-- 전체틀 -->